//
//  DatabaseRequest.m
//  GKZYAid
//
//  Created by lanou3g on 16/2/27.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "DatabaseRequest.h"

@implementation DatabaseRequest

+(void)requestMessageUrlString:(NSString *)urlString didFished:(SUCCEE)succeed{

    NSURL *url = [NSURL URLWithString:urlString];
        
    NSURLSession *session = [NSURLSession sharedSession];
        
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
        
    NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
           
        if (data) {
            //主线程调用:
            dispatch_async(dispatch_get_main_queue(), ^{
                    
                if (succeed) {
                    
                    succeed(data);
                }
            });
        }
    }];
    [task resume];
}


@end
